<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <title>微赢智能信息管理系统</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <!-- VENDOR CSS -->
    <link rel="stylesheet" th:href="@{/assets/vendor/bootstrap/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/font-awesome/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/linearicons/style.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/chartist/css/chartist-custom.css}">
    <!-- MAIN CSS -->
    <link rel="stylesheet" th:href="@{/assets/css/main.css}">
    <!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
    <link rel="stylesheet" th:href="@{/assets/css/demo.css}">
    <!-- ICONS -->
    <link rel="apple-touch-icon" sizes="76x76" th:href="@{/assets/img/apple-icon.png}">
    <link rel="icon" type="image/png" sizes="96x96" th:href="@{/assets/img/favicon.png}">
    <script th:src="@{/assets/vendor/jquery/jquery.min.js}"></script>
    <script th:src="@{/assets/vendor/bootstrap/js/bootstrap.min.js}"></script>
    <script th:src="@{/assets/vendor/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
    <script th:src="@{/assets/vendor/jquery.easy-pie-chart/jquery.easypiechart.min.js}"></script>
    <script th:src="@{/assets/vendor/chartist/js/chartist.min.js}"></script>
    <script th:src="@{/assets/scripts/klorofil-common.js}"></script>
    <link rel="stylesheet" th:href="@{/assets/bootstrap-table/bootstrap-table.css}">
    <script th:src="@{/assets/bootstrap-table/bootstrap-table.js}"></script>
    <script th:src="@{/assets/bootstrap-table/bootstrap-table-filter-control.js}"></script>
    <script th:src="@{/assets/bootstrap-table/bootstrap-table-zh-CN.js}"></script>
    <script th:src="@{/assets/bootstrap-table/bootstrap-table-fixed-columns.js}"></script>
    <link rel="stylesheet" th:href="@{/assets/bootstrap-table/bootstrap-editable.css}">
    <script th:src="@{/assets/bootstrap-table/bootstrap-editable.js}"></script>
    <script th:src="@{/assets/bootstrap-table/bootstrap-table-editable.js}"></script>
</head>
<body>
<div id="wrapper">
    <!-- NAVBAR -->
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="brand">
            <a th:href="@{/index}" href="index.html"><img th:src="@{/assets/img/logo-dark.png}" alt="Klorofil Logo"
                                                          class="img-responsive logo"></a>
        </div>
        <div class="container-fluid">
            <div class="navbar-btn">
                <button type="button" class="btn-toggle-fullwidth"><i class="lnr lnr-arrow-left-circle"></i></button>
            </div>
            <div id="navbar-menu">
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"><img th:src="@{/assets/img/user.png}"
                                                                                        class="img-circle" alt="Avatar">
                            <span th:text="${session.loginSysUserName}">Samuel</span> <i
                                    class="icon-submenu lnr lnr-chevron-down"></i></a>
                        <ul class="dropdown-menu">
                            <li><a th:href="@{/logout}"><i class="lnr lnr-exit"></i> <span>退出</span></a></li>
                        </ul>
                    </li>
                    <!-- <li>
                        <a class="update-pro" href="#downloads/klorofil-pro-bootstrap-admin-dashboard-template/?utm_source=klorofil&utm_medium=template&utm_campaign=KlorofilPro" title="Upgrade to Pro" target="_blank"><i class="fa fa-rocket"></i> <span>UPGRADE TO PRO</span></a>
                    </li> -->
                </ul>
            </div>
        </div>
    </nav>
    <!-- END NAVBAR -->
    <!-- LEFT SIDEBAR -->
    <div id="sidebar-nav" class="sidebar">
        <div class="sidebar-scroll">
            <nav>
                <ul class="nav">
                    <shiro:hasPermission name="jggl">
                        <li>
                            <a href="#subPages1" data-toggle="collapse" class="collapsed "><i
                                    class="lnr lnr-apartment"></i>
                                <span>机构管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages1" class="collapse">
                                <ul class="nav">
                                    <shiro:hasPermission name="jgxxgl">
                                        <li><a th:href="@{/hospital}">
                                            <span>机构信息管理</span></a>
                                        </li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="tp">
                                        <li><a th:href="@{/images}" class=""> <span>图片</span></a>
                                        </li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="jgflgl">
                                        <li><a th:href="@{/hospitalField}" class="">
                                            <span>机构分类管理</span></a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="bmgl">
                                        <li><a th:href="@{/hospitalDepartment}" class="">
                                            <span>部门管理</span></a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="jgjjgl">
                                        <li><a th:href="@{/hospitalProfile}" class="">
                                            <span>机构简介管理</span></a></li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="qxgl">
                        <li><a th:href="@{/hospitalPermission}" class=""><i class="lnr lnr-inbox"></i>
                            <span>权限管理</span></a></li>
                    </shiro:hasPermission>
                    <!--  <li><a th:href="@{/user}" class=""><i class="lnr lnr-users"></i>
                          <span>用户管理</span></a></li>-->
                    <shiro:hasPermission name="zjgl">
                        <li>
                            <a href="#subPages" data-toggle="collapse" class="collapsed"><i
                                    class="lnr lnr-graduation-hat"></i>
                                <span>专家管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages" class="collapse ">
                                <ul class="nav">
                                    <shiro:hasPermission name="zjxxgl">
                                        <li><a th:href="@{/master}" class="">专家信息管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="zjdtmx">
                                        <li><a th:href="@{/masterScore}" class="">专家答题明细</a>
                                        </li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="wtgl">
                        <li><a th:href="@{/question}" class=""><i class="lnr lnr-menu-circle"></i>
                            <span>问题管理</span></a></li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="hmd">
                        <li><a th:href="@{/blackList}" class=""><i class="lnr lnr-sad"></i> <span>黑名单</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="dd">
                        <li><a th:href="@{/wxOrder}" class=""><i class="lnr lnr-list"></i> <span>订单</span></a></li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="yhhdgl">
                        <li><a th:href="@{/hospitalActivity}" class=""><i class="lnr lnr-star"></i>
                            <span>优惠活动管理</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="ztjz">
                        <li><a th:href="@{/knowledge}" class=""><i class="lnr lnr-diamond"></i> <span>专题讲座</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="yygl">
                        <li>
                            <a href="#subPages2" data-toggle="collapse" class="collapsed"><i
                                    class="lnr lnr-pencil"></i>
                                <span>预约管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages2" class="collapse ">
                                <ul class="nav">
                                    <shiro:hasPermission name="yyslgl">
                                        <li><a th:href="@{/guahao}" class="">预约数量管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="xxgl">
                                        <li><a th:href="@{/hospitalSchedule}" class="">信息管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="lscx">
                                        <li><a th:href="@{/guahaoHistory}" class="">历史查询</a>
                                        </li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                </ul>
            </nav>
        </div>
    </div>
    <div class="main">
        <!-- MAIN CONTENT -->
        <div class="main-content">
            <div class="container-fluid">
                <div class="row">
                    <button id="btn-search" type="button" onclick="addKnowledgeModal()"
                            class="btn btn-info btn-sm rightSize" style="margin-left: 1px">
                        <span class="glyphicon glyphicon-search" aria-hidden="true"></span>新增
                    </button>
                </div>
                <div class="row">
                    <table id="knowledgeTable">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<!--模态框-->
<div class="modal fade" id="addKnowledgeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <form role="form" id="addKnowledgeForm">
                    <div class="form-group">
                        <label for="headline">标题</label>
                        <input type="text" class="form-control" id="headline" name="headline" placeholder="标题">
                    </div>
                    <div class="form-group">
                        <label for="content">内容</label>
                        <textarea type="text" class="form-control" id="content" name="content"
                                  style="width: 550px;height: 100px"
                                  placeholder="请输入内容"></textarea>
                    </div>
                    <div class="form-group">
                        <label>图片1</label>
                        <input type="file" name="knowledgeImg">
                    </div>
                    <div class="form-group">
                        <label>图片2</label>
                        <input type="file" name="knowledgeImg">
                    </div>
                    <div class="form-group">
                        <label>图片3</label>
                        <input type="file" name="knowledgeImg">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="addKnowledge()">提交</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="deleteKnowledgeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <h2 style="text-align: center">确定要删除？</h2>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="deleteKnowledge()">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="updateKnowledgeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <form role="form" id="updateKnowledgeForm">
                    <div class="form-group">
                        <label for="headline">标题</label>
                        <input type="text" class="form-control" id="knowledgeHeadline" name="knowledgeHeadline"
                               placeholder="标题">
                    </div>
                    <div class="form-group">
                        <label for="content">内容</label>
                        <textarea type="text" class="form-control" id="knowledgeContent" name="knowledgeContent"
                                  style="width: 550px;height: 100px"
                                  placeholder="请输入内容"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="updateKnowledge()">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<script>
    var updateKnowledgeId1;
    $(function () {
        //1.初始化Table
        var oTable = new TableInit();
        oTable.Init();
        //2.初始化Button的点击事件
        var oButtonInit = new ButtonInit();
        oButtonInit.Init();
    });
    var TableInit = function () {
        var oTableInit = new Object();
        //初始化Table
        oTableInit.Init = function () {
            $('#knowledgeTable').bootstrapTable({
                url: '/fenda/findKnowledge',         //请求后台的URL（*）
                method: 'get',                      //请求方式（*）
                toolbar: '#toolbar',                //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                     //是否显示分页（*）
                sortable: false,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                queryParams: oTableInit.queryParams,//传递参数（*）
                sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 20, 30],        //可供选择的每页的行数（*）
                /* search: true, */                      //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                strictSearch: false,
                minimumCountColumns: 1,             //最少允许的列数
                clickToSelect: false,                //是否启用点击选中行
                height: document.body.clientHeight,                      //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                uniqueId: "id",                     //每一行的唯一标识，一般为主键列
                cardView: false,                    //是否显示详细视图
                detailView: false,                   //是否显示父子表
                columns: [{
                    width: 250,
                    valign: "middle",
                    align: 'center',
                    field: 'headline',
                    title: '标题',
                }, {
                    valign: "middle",
                    align: 'center',
                    field: 'content',
                    title: '内容',
                }, {
                    field: 'knowledgeImgList',
                    title: '图片',
                    align: 'center',
                    valign: "middle",
                    width: 260,
                    formatter: function (value, row, index) {
                        var imgHTML = "";
                        $(value).each(function (index, content) {
                            imgHTML += '<img src="' + content.imgPath + '" style="width:60px;height: 60px;margin: 5px;">';
                        });
                        return imgHTML;
                    }
                }, {
                    align: 'center',
                    valign: "middle",
                    title: '操作',
                    width: 120,
                    formatter: function (value, row, index) {
                        return '<button  type="button" style="width: 100px" class="btn btn-danger btn-sm" onclick="deleteKnowledgeModal(' + row.knowledgeId + ')">删除<button style="width: 100px" type="button" class="btn btn-primary btn-sm" onclick="updateKnowledgeModal(' + row.knowledgeId + ')">修改</button>';
                    }
                },],
                //注册加载子表的事件。注意下这里的三个参数！
                onExpandRow: function (index, row, $detail) {
                    oTableInit.InitSubTable(index, row, $detail);
                }
            });
        };
        //得到查询的参数
        oTableInit.queryParams = function (params) {
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,   //页面大小
                offset: params.offset,  //页码
                hospitalName: $("#hospitalName").val(),
                userName: $("#userName").val(),
                isSolved: $("#isSolved").val(),
                haveImg: $("#haveImg").val(),
                questionClass: $("#questionClass").val(),
                askDate: $("#startDate").val(),
                maxDate: $("#endDate").val(),
                questionMoney: $("#questionMoney").val(),
                questonContent: $("#questionContent").val(),
                answerStatus: $("#answerStatus").val()
                /*                departmentname: $("#txt_search_departmentname").val(),
                 statu: $("#txt_search_statu").val(),*/
            };
            return temp;
        };
        return oTableInit;
    };
    var ButtonInit = function () {
        var oInit = new Object();
        var postdata = {};
        oInit.Init = function () {
            //初始化页面上面的按钮事件
        };
        return oInit;
    };
    //使checkbox居中对齐
    $("#hospital-table").on("load-success.bs.table", function (e, data) {
        $(".bs-checkbox").css("vertical-align", "middle");
    });
    function addKnowledgeModal() {
        $("#addKnowledgeModal").modal({
            keyboard: true
        });
    }
    function addKnowledge() {
        $.ajax({
            url: '/fenda/addKnowledge',
            type: 'POST',
            cache: false,
            data: new FormData($('#addKnowledgeForm')[0]),
            processData: false,
            contentType: false,
            beforeSend: function () {
            },
            complete: function () {
            },
        }).done(function (res) {
            $("#addKnowledgeModal").modal('hide');
        }).fail(function (res) {
        });
    }
    var deleteKnowledgeId;
    function deleteKnowledgeModal(knowledgeId) {
        deleteKnowledgeId = knowledgeId;
        $("#deleteKnowledgeModal").modal({
            keyboard: true
        });
    }
    function deleteKnowledge() {
        $.ajax({
            url: "/fenda/deleteKnowledge",
            data: {
                knowledgeId: deleteKnowledgeId,
            },
            success: function () {
                $("#deleteKnowledgeModal").modal('hide');
                $('#knowledgeTable').bootstrapTable('refresh', {
                    silent: true
                });
            }
        });
    }
    function updateKnowledgeModal(updateKnowledgeId) {
        $.ajax({
            url: "/fenda/findKnowledgeById",
            data: {
                knowledgeId: updateKnowledgeId,
            },
            success: function (res) {
                updateKnowledgeId1=updateKnowledgeId;
                $("#knowledgeHeadline").val(res.headline);
                $("#knowledgeContent").val(res.content);
                $("#updateKnowledgeModal").modal({
                    keyboard: true
                });
            }
        });
    }
    function updateKnowledge() {
        $.ajax({
            url: "/fenda/updateKnowledge",
            data: {
                knowledgeId: updateKnowledgeId1,
                headline: $("#knowledgeHeadline").val(),
                content: $("#knowledgeContent").val()
            },
            success: function () {
                $("#updateKnowledgeModal").modal('hide');
            }
        })
    }
</script>
</body>
</html>